<template>
	<div class="main" ref='remove'>
		<div class="admissionWrap">
			<select-picker :titles="areas" v-on:showPick1="showPicks" v-on:showPickCty1="showPicksCty" :pov='value1[0]' :cty='value2[0]'></select-picker>
			<div class="otherSpc">
				<admission-line :lineData="lineData1" :titleData='titleData1'></admission-line>
			</div>
			<select-picker :pts="true" titles="专业录取分数线" v-on:showPick1="showPicks1" v-on:showPickCty1="showPicksCty1"
			 v-on:showPickType1='showPicksType' :pty="value3[0]" :pov='value4[0]' :cty='value5[0]'></select-picker>
			<admission-line :lineData="lineData2" :titleData='titleData2' :ssreStyle="true"></admission-line>
		</div>
		<popup-picker :show.sync="showPopupPicker" :show-cell="false" :data="list1" v-model="value1" @on-show="onShow"
		 @on-hide="onHide" @on-change="onChange"></popup-picker>
		<popup-picker :show.sync="showPopupPicker1" :show-cell="false" :data="list2" v-model="value2" @on-change="onChange1"></popup-picker>
		<popup-picker :show.sync="showPopupPicker2" :show-cell="false" :data="list3" v-model="value3" @on-change="onChange2"></popup-picker>
		<popup-picker :show.sync="showPopupPicker3" :show-cell="false" :data="list4" v-model="value4" @on-change="onChange3"></popup-picker>
		<popup-picker :show.sync="showPopupPicker4" :show-cell="false" :data="list5" v-model="value5" @on-change="onChange4"></popup-picker>
	</div>
</template>
<script>
	import admissionLine from '~/components/admissionLine'
	import selectPicker from './selectPicker'
	import { getBatch, examinees, majorExaminees } from "~/api/colleges";
	import ls from 'store2';
	import {

	} from 'vux'
	import {
		PopupPicker
	} from 'vux'

	import {
		format
	} from '~/plugins/filter';
	export default {
// 		head: {
// 			title: '录取'
// 		},
		components: {
			PopupPicker,
			admissionLine,
			selectPicker
		},
		props: {
			// lineData1:Array
		},
		data() {
			return {
				areas: '院校分数线',
				titleData1: ['招生批次', '最低分', '最低位次', '计划数', '投档人数'],
				lineData1: [''],
				titleData2: ['招生专业', '最高分', '最低分', '平均分', '最低位次', '录取数'],
				lineData2: [''],
				godown: false,

				showPopupPicker: false,
				showPopupPicker1: false,
				showPopupPicker2: false,
				showPopupPicker3: false,
				showPopupPicker4: false,
				list1: [
					['2019','2018', '2017', '2016']
				],
				list2: [
					['理科', '文科']
				],
				list3: [
					// ['本科一批', '本科二批', '本科三批', '专科批']
				],
				list4: [
					['2019','2018', '2017', '2016']
				],
				list5: [
					['理科', '文科'] 
				],
				value1: ['2019'],
				value2: ['理科'],
				value3: ['本科一批'],
				value4: ['2018'],
				value5: ['理科']
			}
		},
		created(){
			
		},
		mounted: function() {
			
			this.showPici()
			this.showSortLine()
			
		},
		destroyed() {},
		watch: {

		},
		methods: {
			showPici() {
				getBatch({
					"academyCode": this.commonJs.GetUrlParam('academyCode'),
					"province": ls.get('userArea')

				}).then(res => {
					if (res.code === '0') {
					
						let ary = [];
	
						res.data.forEach(item => {
							ary.push(item);
						})
						this.list3.push(ary);
						this.value3[0] = res.data[0]
					
						this.showMajorLine()
						
					}
				}).catch((error) => {
					// this.$hideLoading();
					this.$vux.toast.text('暂无数据');
				})
			},
			showSortLine() {			
				examinees({
					"academyCode": this.commonJs.GetUrlParam('academyCode'),
					"type": this.value2[0],
					"year": this.value1[0],
					"province": ls.get('userArea')
				}).then(res => {
					if (res.code === '0') {
						this.areas = '院校分数线(' + ls.get('userArea') + ')'
						let datas = res.data;
						let ary = [];
						datas.forEach(item => {
							item.level ? item.level = item.level : item.level = '--';
							item.minScore ? item.minScore = item.minScore : item.minScore = '--';
							item.minRanking ? item.minRanking = item.minRanking : item.minRanking = '--';
							item.numPlan ? item.numPlan = item.numPlan : item.numPlan = '--';
							item.numArchive ? item.numArchive = item.numArchive : item.numArchive = '--';
							ary.push({

								main: [item.level, item.minScore, item.minRanking, item.numPlan, item.numArchive]
							})

						})
						this.lineData1 = ary;						
					}
					this.$nextTick(() => {
						// this.$hideLoading();
					})
					
				}).catch((error) => {
					// this.$hideLoading();
					this.$vux.toast.text('暂无数据');
				})
			},
			showMajorLine() {
		
				majorExaminees({
					"academyCode": this.commonJs.GetUrlParam('academyCode'),
					"type": this.value5[0],
					"year": this.value4[0],
					"level": this.value3[0],
					"province": ls.get('userArea')
				}).then(res => {
					if (res.code === '0') {
						let datas = res.data;
						let ary = [];
						datas.forEach(item => {
							item.majorName ? item.majorName = item.majorName : item.majorName = '--';
							item.maxScore ? item.maxScore = item.maxScore : item.maxScore = '--';
							item.minScore ? item.minScore = item.minScore : item.minScore = '--';
							item.avgScore ? item.avgScore = item.avgScore : item.avgScore = '--';
							item.minRanking ? item.minRanking = item.minRanking : item.minRanking = '--';
							item.number ? item.number = item.number : item.number = '--';
							ary.push({

								main: [item.majorName, item.maxScore, item.minScore, item.avgScore, item.minRanking, item.number]
							})
						})
						this.lineData2 = ary;
						
					}
					this.$nextTick(() => {
						this.$hideLoading();
					})
				}).catch((error) => {
					this.$vux.toast.text('暂无数据');
					this.$hideLoading();
				})
			},
			showPicks() {
				this.showPopupPicker = true;

			},
			showPicks1() {
				this.showPopupPicker3 = true;

			},
			showPicksCty() {
				this.showPopupPicker1 = true;

			},
			showPicksCty1() {
				this.showPopupPicker4 = true;

			},
			showPicksType() {
				this.showPopupPicker2 = true;
			},

			onChange(val) {
				this.value1 = val;
				this.showSortLine()
			},
			onChange1(val) {

				this.value2 = val;
				this.showSortLine()
			},
			onChange2(val) {
				// this.$loading('open')
				this.value3 = val;
				this.showMajorLine();
			},
			onChange3(val) {
				// this.$loading('open')
				this.value4 = val;
				this.showMajorLine();
			},
			onChange4(val) {
				// this.$loading('open')
				this.value5 = val;
				this.showMajorLine();
			},
			onShow() {
			
			},
			onHide(type) {
		
			},
			goto(routerName, queryData) {
				this.$router.push({
					path: routerName,
					query: {
						type: queryData
					}
				});
			},

		},
		beforeDestroy() {

		}

	}
</script>

<style scoped lang="less">
	.loading-layer {
		opacity: 0
	}

	.admissionWrap {
		width: 7.5rem;
		height: auto;
		background: #fff;
		padding-top: 0.2rem;
	}

	.vux-cell-box:not(:first-child):before {
		border-top: none !important;
	}

	// .vux-cell-box:not(:first-child):before
	.otherSpc .admissionGezi .adSmallBox .adSmallLine span:nth-of-type(1) {
		text-align: center !important;
	}
</style>
